package com.ruoyi.web.controller.safety;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.safety.domain.SubstationStatusDict;
import com.ruoyi.safety.service.ISubstationStatusDictService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分站运行状态字典Controller
 * 
 * @author ruoyi
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/safety/substationStatusDict")
public class SubstationStatusDictController extends BaseController
{
    @Autowired
    private ISubstationStatusDictService substationStatusDictService;

    /**
     * 查询分站运行状态字典列表
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:list')")
    @GetMapping("/list")
    public TableDataInfo list(SubstationStatusDict substationStatusDict)
    {
        startPage();
        List<SubstationStatusDict> list = substationStatusDictService.selectSubstationStatusDictList(substationStatusDict);
        return getDataTable(list);
    }

    /**
     * 导出分站运行状态字典列表
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:export')")
    @Log(title = "分站运行状态字典", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SubstationStatusDict substationStatusDict)
    {
        List<SubstationStatusDict> list = substationStatusDictService.selectSubstationStatusDictList(substationStatusDict);
        ExcelUtil<SubstationStatusDict> util = new ExcelUtil<SubstationStatusDict>(SubstationStatusDict.class);
        util.exportExcel(response, list, "分站运行状态字典数据");
    }

    /**
     * 获取分站运行状态字典详细信息
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(substationStatusDictService.selectSubstationStatusDictById(id));
    }

    /**
     * 新增分站运行状态字典
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:add')")
    @Log(title = "分站运行状态字典", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SubstationStatusDict substationStatusDict)
    {
        return toAjax(substationStatusDictService.insertSubstationStatusDict(substationStatusDict));
    }

    /**
     * 修改分站运行状态字典
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:edit')")
    @Log(title = "分站运行状态字典", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SubstationStatusDict substationStatusDict)
    {
        return toAjax(substationStatusDictService.updateSubstationStatusDict(substationStatusDict));
    }

    /**
     * 删除分站运行状态字典
     */
    @PreAuthorize("@ss.hasPermi('safety:dict:remove')")
    @Log(title = "分站运行状态字典", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(substationStatusDictService.deleteSubstationStatusDictByIds(ids));
    }
}
